home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyo (Python 2.5)
-
- from mapping import Storage
- from itertools import izip
- from random import getrandbits
-
- def hex2bin(s):
- return ''.join((lambda .0: for x in .0:
- chr(int(x, 16)))(s.split()))
-
-
- def rand32():
- import random
- return random.randint(1, 0xFFFFFFFFL)
-
-
- def getrandbytes(n):
- return ''.join((lambda .0: for _i in .0:
- chr(getrandbits(8)))(range(n)))
-
-
- def rol(i, n, bits = 32):
- (div, mod) = divmod(i << n, 2 ** bits - 1)
- return mod | div >> bits
-
-
- def ror(i, n, bits = 32):
- return (i % 2 ** n << bits - n) + (i >> n)
-
-
- def bitfields(*names):
- bits = [ 2 ** i for i in xrange(len(names)) ]
- return Storage(izip(names, bits))
-
-
- class BitFlags(object):
-
- def __init__(self, names):
- self._field = bitfields(*names)
- self.__dict__.update(dict.fromkeys(names, False))
-
-
- def Pack(self):
- return reduce((lambda a, b: a | b), (map,)((lambda x: getattr(self._field, x) * getattr(self, x)), self._field))
-
-
- def Unpack(self, val):
- _[1]
-
-
-
- def leftrotate(s, shift, size = 32):
- max = pow(2, size)
- s = s % max << shift
- (wrap, s) = divmod(s, max)
- return s | wrap
-
-
- def utf7_to_int(databuf):
- total = i = 0
- more_bytes = True
- while more_bytes:
- byte = ord(databuf[i])
- more_bytes = bool(byte & 128)
- total |= (byte & 127) * (1 << 7 * i)
- i += 1
- return (total, i)
-
- if __name__ == '__main__':
- import doctest
- doctest.testmod(verbose = True)
-
-